package com.cloudlead.fleetAction.action;

import com.cloudlead.common.lang.BusinessModule;
import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.lang.persistence.Page;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.fleetAction.BusinessModules;
import com.cloudlead.fleetAction.service.BaseCarEditSer;
import com.cloudlead.fleetService.BaseCarService;
import com.cloudlead.fleetService.vo.BaseCarVo;
import com.cloudlead.fleetService.vo.BaseGpsVo;
import com.cloudlead.fleetService.vo.TbCarOperationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;

/**
 * Created by 20150817 on 2015/9/1.
 */
@Controller
public class BaseCarEditActionFactory extends AbstractActionFactory implements BaseCarService{
    public BaseCarEditActionFactory() {
        super(BusinessModules.CarGL);
    }
    @Autowired
    BaseCarEditSer baseCarEditSer;

    @Action
    @Order(1)
    @Label("创建车辆")
    @Override
    public void createCar(BaseCarVo vo) {
        baseCarEditSer.createCar(vo);
    }

    @Action
    @Order(2)
    @Label("编辑车辆")
    @Override
    public void editCar(BaseCarVo vo) {
        baseCarEditSer.editCar(vo);
    }

    @Action
    @Order(3)
    @Label("单值查询")
    @Override
    public Object findOneCar(BaseCarVo vo) {
        return baseCarEditSer.findOneCar(vo);
    }

    @Action
    @Order(4)
    @Label("分页查询")
    @Override
    public Page<BaseCarVo> findAllCar(BaseCarVo vo,@Label("页数") int page,@Label("条数") int size) {
        return baseCarEditSer.findAllCar(vo, page, size);
    }

    @Action
    @Order(5)
    @Label("删除车辆")
    @Override
    public void delCar(@NotNull@Label("ID")String id) {
        baseCarEditSer.delCar(id);
    }

    @Action
    @Order(9)
    @Label("恢复车辆")
    @Override
    public void hfCar(String id) {
        baseCarEditSer.hfCar(id);
    }


    @Action
    @Order(6)
    @Label("分页Easyui")
    @Override
    public EasyuiGridData carList(BaseCarVo vo,int page,int rows){
        return new EasyuiGridData(baseCarEditSer.findAllCar(vo, page, rows),
                "id,licencePlate,weixinNo,weixinPassword,onlineTask,engineNumber,status,comments," +
                        "baseDriver.id baseDriver," +
                        "baseDriver.name driverName," +
                        "baseFleet.id fleetId," +
                        "baseFleet.fleetName fleetName," +
                        "baseCompany.id baseCompany," +
                        "baseCompany.companyName companyName," +
                        "baseCompany.companyType companyType," +
                        "baseG.id gpsId," +
                        "baseG.gpsName gpsName");
    }
    @Action
    @Order(7)
    @Label("解除微信")
    @Override
    public void relieveWX(@NotNull@Label("ID")String id) {
        baseCarEditSer.relieveWX(id);
    }

    @Action
    @Order(8)
    @Label("查询Gps")
    @Override
    public EasyuiGridData findAllGps(BaseGpsVo baseGpsVo, @Label("页数")int page,@Label("条数") int size) {
        return new EasyuiGridData(baseCarEditSer.finAllGps(baseGpsVo,page,size),"fleet.id fleetId,gpsName,gpsType,id,passWord,url,userName");
    }
    @Action
    @Order(10)
    @Label("查询动态")
    @Override
    public EasyuiGridData findAllCarS(TbCarOperationVo vo, int page, int size) {
        return new EasyuiGridData(baseCarEditSer.findAllCarS(vo, page, size),"amount,car.id carId,car.licencePlate licencePlate,createBy,createDate,id,operation,remark");
    }

    @Action
    @Order(11)
    @Label("修改状态同时创建动态信息")
    @Override
    public void editCarStatus(BaseCarVo vo) {
        baseCarEditSer.editCarStatus(vo);
    }

}
